package com.controller;

import com.entity.PageBean;
import com.entity.PurOrder;
import com.entity.Result;
import com.entity.Supplier;
import com.group.PurOrderAddGroup;
import com.group.PurOrderModifyGroup;
import com.group.SupplierAddGroup;
import com.service.PurOrderService;
import com.service.SupplierService;
import com.vo.PurOrderVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/purorder")
public class PurOrderController {
    @Autowired
    private PurOrderService purOrderService;

    @RequestMapping("/getOrderList/{pageIndex}/{pageSize}")
    public Result getOrderList(
          @PathVariable("pageIndex") Integer pageIndex,
          @PathVariable("pageSize") Integer pageSize,
          @RequestBody PurOrderVO purOrderVO
    ){
        PageBean<PurOrder> pageBean = purOrderService.getOrderList(pageIndex, pageSize, purOrderVO);
        return Result.ok(pageBean);
    }

//    //获得订单编号
//    @RequestMapping("/getOrdernum")
//    public Result getOrdernum(){
//        purOrderService.getOrdernum();
//        return Result.ok();
//    }

    //增加
    @PostMapping("/addOrderList")
    public Result addOrderList(@Validated(PurOrderAddGroup.class) @RequestBody PurOrder purOrder){
        purOrderService.addOrderList(purOrder);
        return Result.ok();
    }

    //通过eid删除
    @RequestMapping("/removeOrderByOid/{oid}")
    public Result removeOrderByOid(@PathVariable("oid")int oid){
        purOrderService.removeOrderByOid(oid);
        return Result.ok();
    }
    @PostMapping("/modifyOrderList")
    public Result modifyOrderList(@RequestBody PurOrder purOrder){
        purOrderService.updateOrderList(purOrder);
        return Result.ok();
    }

    //更新是否入库的状态、
    @PostMapping("/modifyOrderstatus")
    public Result modifyOrderstatus(@RequestBody PurOrder purOrder){
        purOrderService.updateOrderstatus(purOrder);
        return Result.ok();
    }

}
